package com.hall.weaponenhancement.ctrl;

import com.hall.TripletProcessResult;
import com.hall.items.aggr.MyWeaponLevel;
import com.hall.items.aggr.MyWeaponProperties;
import com.hall.items.msg.MsgSender;
import com.hall.items.service.ItemsService;
import com.hall.weaponenhancement.aggr.GoldAccount;
import com.hall.weaponenhancement.service.WeaponEnhancementService;
import com.sharecommon.view.CommonVO;
import dml.accounting.aggr.TransferResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/we")
public class WeaponEnhancementController {

    @Autowired
    private MsgSender msgSender;

    @Autowired
    private WeaponEnhancementService weaponEnhancementService;

    @Autowired
    private ItemsService itemsService;

    @RequestMapping("/enhanceweapon")
    @ResponseBody
    public CommonVO enhanceweapon(String playerId, long weaponId) {
        TripletProcessResult<MyWeaponLevel, MyWeaponProperties, TransferResult<GoldAccount>> rslt = weaponEnhancementService
                .enhanceWeapon(Long.valueOf(playerId), weaponId);
        msgSender.sendProcess(true);
        if (rslt == null) {
            return CommonVO.unsuccess("enhance weapon faild");
        }
        return CommonVO.success();
    }

}
